package edu.ntu.cloudroid.model.friend;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.jdo.annotations.FetchGroup;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;


import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;

import edu.ntu.cloudroid.model.IDs.UploadID;
import edu.ntu.cloudroid.model.IDs;
import edu.ntu.cloudroid.model.UserData;
import edu.ntu.cloudroid.model.data.AbstractData;
import edu.ntu.cloudroid.model.data.DetachedData;
import edu.ntu.cloudroid.model.policy.PolicyInfo;
import edu.ntu.cloudroid.model.profile.ProfileData;
import edu.ntu.cloudroid.server.backendservice.Utilities;

/**
 * @author ttadinh
 * Similar to FriendInfo, but each group also contains a privacy preference
 */
public class GroupInfo implements DetachedData, Serializable{
	
	public static final int NEW = 0;
	public static final int ADD = 1; //adding new member only
	public static final int REMOVE = 2;
	public static final int REPLY = 3;
	
	private String ownerName;
	private String groupName;
	private Set<String> members;
	
	private PolicyInfo policy;
	
	private int type;
	
	public GroupInfo(String owner, String groupName, Set<String> mem, int type){
		this.groupName = groupName;
		this.ownerName = owner;
		this.members = mem;
		this.type = type;
	}

	//adding a new member, or brand new object
	public int getType(){
		return this.type;
	}
	
	public void setPolicyInfo(PolicyInfo pi){
		this.policy = pi;
	}
	
	public PolicyInfo getGroupPolicy(){
		return this.policy;
	}
	
	public String getGroupName(){
		return this.groupName;
	}
	
	//convert the member strings to keys
	public Set<String> getGroupMemberKeys(){
		return this.members;
	}
	
	public String getOwnerName() {
		return ownerName;
	}

	public void setOwnerName(String ownerName) {
		this.ownerName = ownerName;
	}

	public Set<String> getMembers() {
		return members;
	}

	public void setMembers(Set<String> members) {
		this.members = members;
	}

	@Override
	public UploadID getUploadID() {
		return IDs.UploadID.Group;
	}

	@Override
	public AbstractData toGAEData() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}
	
	
}
